<!DOCTYPE html>
<html
    xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
    xmlns:th="http://www.thymeleaf.org"
    layout:decorate="~{layout}">

<head>
    <title>Message Format Configuration</title>
</head>

<body>
<section layout:fragment="content">
    <div class="container">

        <!-- Custom Message Formats -->
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fa fa-align-justify"></i>
                        Custom Message Formats
                        <div class="btn-group float-right" role="group" aria-label="Button group">
                            <a class="btn" href="/help#deserializers" style="padding-bottom: 0;">
                                <i class="icon-question"></i>
                                &nbsp; Help
                            </a>

                            <a class="btn" href="/configuration/messageFormat/create" style="padding-bottom: 0;">
                                <i class="icon-settings"></i>
                                &nbsp;Create new
                            </a>
                        </div>
                    </div>
                    <div class="card-body">
                        <table class="table table-bordered table-striped table-sm">
                            <thead>
                            <tr>
                                <th>Name</th>
                                <th>Class</th>
                                <th>Type</th>
                                <th class="text-right">Action</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:if="${customMessageFormats.isEmpty()}">
                                <td colspan="4" align="center">
                                    No Custom Message Formats Found.
                                </td>
                            </tr>
                            <tr th:unless="${customMessageFormats.isEmpty()}" th:each="messageFormat : ${customMessageFormats}">
                                <td th:text="${messageFormat.name}"></td>
                                <td th:text="${messageFormat.classpath}"></td>
                                <td th:text="${messageFormat.isDefaultFormat()} ? 'Default' : 'Custom'"></td>
                                <td class="text-right">
                                    <div class="dropdown">
                                        <button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            Actions
                                        </button>
                                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                            <a class="dropdown-item" th:href="@{/configuration/messageFormat/edit/{id}(id=${messageFormat.id})}">
                                                <i class="fa fa-edit"></i>
                                                Edit
                                            </a>
                                            <form th:action="@{/configuration/messageFormat/delete/{id}(id=${messageFormat.id})}" method="post">
                                                <button class="dropdown-item" onclick="return confirm('Are you sure?');" type="submit">
                                                    <i class="fa fa-remove"></i>
                                                    Delete
                                                </button>
                                            </form>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <!--/.col-->
        </div>

        <!-- Default Message Formats -->
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <i class="fa fa-align-justify"></i>
                        Default Message Formats
                    </div>
                    <div class="card-body">
                        <table class="table table-bordered table-striped table-sm">
                            <thead>
                            <tr>
                                <th>Name</th>
                                <th>Class</th>
                                <th>Type</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="messageFormat : ${defaultMessageFormats}">
                                <td th:text="${messageFormat.name}"></td>
                                <td th:text="${messageFormat.classpath}"></td>
                                <td th:text="${messageFormat.isDefaultFormat()} ? 'Default' : 'Custom'"></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <!--/.col-->
        </div>
    </div>
</section>

</body>
</html>